"use strict";
cc._RF.push(module, '6344ecVWT1J94dIU8SGrN6O', 'KSSDK');
// scripts/KSSDK.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n13,
    i = void 0 && (void 0).__extends || (_n13 = function n(t, e) {
  return (_n13 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n13(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
});

Object.defineProperty(o, "__esModule", {
  value: !0
});

var s = t("BaseSdk"),
    r = t("Common"),
    c = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e._recorderShareFunc = null, e._musicPauseFunc = null, e._musicPauseThis = null, e._musicResumeFunc = null, e._musicResumeThis = null, e._clipboardData = "", e._playScreenTime = 0, e._screenSpaceTime = 0, e._interstitiaId = "", e._moreGameBtn = null, e._recorder = null, e._videoPath = "", e._recorderStatus = 0, e._recorderEndTime = 0, e._recorderTime = 0, e._groupId = "ballUsers", e._videoId = "2300004842_01", e._bannerId = "", e._screenId = "2300004842_02", e._shareId = "", e._shareTitle = "一起来拼字吧", e._shareDesc = "文字大玩家", e._videoTopics = ["文字大玩家", "文字大玩家小游戏", "解压小游戏"], e._videoLoaded = !1, e._videoOptions = null, e._videoAd = null, e._interstitiaAd = null, e._bannerLoaded = !1, e.lastAdTime = 0, e.gridAd = null, e.banner = null, e.bannerCount = 0, e.screenShow = !1, e.lastshockTime = 0, e.accChangeBack = null, e;
  }

  return i(e, t), e.prototype.init = function () {
    this.lastAdTime = new Date().getTime(), this.loadBanner(!1);
  }, e.prototype.loadBanner = function (t) {
    void 0 === t && (t = !1);
  }, e.prototype.showBanner = function () {
    try {
      this.banner && this.banner.show();
    } catch (t) {}
  }, e.prototype.hideBanner = function () {
    try {
      this.banner && this.banner.hide();
    } catch (t) {}
  }, e.prototype.setKeepScreenOn = function (t) {
    ks.setKeepScreenOn(t);
  }, e.prototype.login = function () {}, e.prototype.getUserInfo = function (t) {
    ks.login({
      success: function success(e) {
        console.log("登录成功", e);
        var o = e.gameToken;
        ks.authorize({
          scope: "scope.userInfo",
          success: function success() {
            console.log("授权获取用户信息成功"), ks.getUserInfo({
              success: function success(e) {
                console.log("获取用户信息成功", e);
                var n = {};
                n.nickName = e.nickName, n.avatarUrl = e.avatarUrl, t.success(n, o);
              },
              fail: function fail(e) {
                console.log("获取信息失败", e), t.fail(o);
              }
            });
          },
          fail: function fail(e) {
            console.log("授权获取用户信息失败: " + JSON.stringify(e)), t.fail(o);
          },
          complete: function complete() {
            console.log("授权获取用户信息完成");
          }
        });
      },
      fail: function fail() {
        console.log("login调用失败"), t.fail();
      }
    });
  }, e.prototype.createMoreGamesButton = function () {}, e.prototype.getOpenDataContext = function () {}, e.prototype.postMessage = function (t) {
    console.log("推送开放数据", t);
  }, e.prototype.startRecorder = function () {}, e.prototype.stopRecorder = function () {}, e.prototype.getIsScreenRecordVideo = function () {
    return "" != this._videoPath && this._recorderEndTime - this._recorderTime > 8e3;
  }, e.prototype.getRecorderState = function () {
    return this._isRecorder;
  }, e.prototype.getRecorderTime = function () {
    return this._recorderEndTime - this._recorderTime;
  }, e.prototype.getLastAdTime = function () {
    return this.lastAdTime;
  }, e.prototype.shareRecorder = function (t) {
    var e = this,
        o = t.query ? t.query : "";
    this._recorder.publishVideo({
      video: e._videoPath,
      query: o,
      callback: function callback(o) {
        if (null != o && null != o) return console.log("分享录屏失败: " + JSON.stringify(o)), t.fail && t.fail(o), void e.showToast("分享失败");
        t.success && t.success(e._videoPath), e._videoPath = "", e.sendEvent({
          key: "shareVideoSuccess"
        }), console.log("分享视频成功");
      }
    }), e.sendEvent({
      key: "shareVideo"
    });
  }, e.prototype.showRewardVideo = function (t) {
    var e = this;
    e._videoOptions = t, e._videoAd ? this._videoAd.show().then(function () {
      console.log("显示广告成功");
    })["catch"](function (t) {
      console.log("显示广告错误", t), e._videoAd.load().then(function () {
        return e._videoAd.show();
      });
    }) : (this._videoAd = ks.createRewardedVideoAd({
      adUnitId: e._videoId
    }), this._videoAd.onLoad(function () {
      console.log("广告加载完成");
    }), this._videoAd.onError(function (t) {
      e._videoLoaded = !1, e.sendEvent({
        key: "videoError",
        value: {
          code: t.errCode
        }
      }), setTimeout(function () {
        e._videoAd.load().then(function () {
          e._videoLoaded = !0;
        });
      }, 3e4), console.log("视频加载失败", t.errCode);
    }), this._videoAd.onClose(function (t) {
      e._videoLoaded = !1, e.lastAdTime = new Date().getTime(), t.isEnded ? (e._videoOptions && e._videoOptions.success && e._videoOptions.success(), e.sendEvent({
        key: "playVideoSuccess"
      })) : e.sendEvent({
        key: "playVideoFail"
      });
    }), this._videoAd.load().then(function () {
      e._videoLoaded = !0, e._videoAd.show().then(function () {
        console.log("显示广告成功");
      })["catch"](function (t) {
        console.log("显示广告错误", t), e._videoAd.load().then(function () {
          return e._videoAd.show();
        });
      });
    })), e.sendEvent({
      key: "playVideo"
    });
  }, e.prototype.setClipboardData = function (t) {
    ks.setClipboardData({
      data: t.data,
      success: function success() {
        t.success && t.success(), console.log("调用剪切板成功", t.data);
      },
      fail: function fail() {
        t.fail && t.fail(), console.log("调用剪切板失败", t.data);
      }
    });
  }, e.prototype.getVideoState = function () {
    return this._videoLoaded;
  }, e.prototype.playScreen = function (t) {
    void 0 === t && (t = 1);
    var e = new Date().getTime();
    e - this.lastAdTime > 18e4 && (this.lastAdTime = e, ks.createInterstitialAd({
      adUnitId: this._screenId
    }).show().then(function () {
      return console.log("插屏 广告显示");
    }));
  }, e.prototype.sendEvent = function (t) {
    t && t.key && console.log("上报事件:", t.key);
  }, e.prototype.vibrateShort = function () {
    var t = new Date().getTime();
    t - this.lastshockTime > 100 && r["default"]._shockOpen && (this.lastshockTime = t, ks.vibrateShort({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateShort调用失败");
      }
    }));
  }, e.prototype.vibrateLong = function () {
    r["default"]._shockOpen && ks.vibrateLong({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateLong调用失败");
      }
    });
  }, e.prototype.showToast = function (t) {
    ks.showToast({
      title: t,
      icon: "none",
      duration: 2e3,
      success: function success() {},
      fail: function fail() {}
    });
  }, e.prototype.share = function (t) {
    ks.shareAppMessage(t);
  }, e.prototype.setLocalStorage = function (t, e) {
    cc.sys.localStorage.setItem(t, e);
  }, e.prototype.getLocalStorage = function (t) {
    return cc.sys.localStorage.getItem(t);
  }, e.prototype.contentSafe = function (t) {
    var e = {
      text: t.content
    };
    this.sendHttpRequest(r["default"].contentSafeKS, e, function (e) {
      e.valid ? t.callBack(!0) : t.callBack(!1);
    }, function () {
      t.callBack(!1);
    });
  }, e.prototype.registerAccChange = function (t) {
    var e = this;
    this.accChangeBack = t, ks.startAccelerometer({
      success: function success(t) {
        console.log("调用开始加速度成功", t.errMsg);
      },
      fail: function fail(t) {
        console.log("调用开始加速度失败", t.errMsg);
      }
    }), ks.onAccelerometerChange(function (t) {
      e.accChangeBack(-t.y.toFixed(2), t.x.toFixed(2), t.z.toFixed(2), e);
    });
  }, e.prototype.unRegisterAccChange = function () {
    ks.stopAccelerometer({
      success: function success(t) {
        console.log("调用停止加速度成功", t.errMsg);
      },
      fail: function fail(t) {
        console.log("调用停止加速度失败", t.errMsg);
      }
    });
  }, e.prototype.onShow = function (t) {
    ks.onShow(function (e) {
      t(e);
    });
  }, e.prototype.getLaunchOptionsSync = function () {
    return ks.getLaunchOptionsSync();
  }, e;
}(s["default"]);

o["default"] = c;

cc._RF.pop();